package com.vichat.user.entity;


import com.vichat.common.constant.I18nConstant;
import com.vichat.common.exception.ViChatException;
import com.vichat.common.util.StringUtil;
import org.apache.commons.lang3.StringUtils;

import javax.persistence.*;

/***************
 *author: autogen
 *version: 2018-11-19 10:01:24.188
 */
@Entity
@Table(name = "agent_user",catalog = "ccsdb")
public class AgentUser implements java.io.Serializable{

	private static final long serialVersionUID = 1L;
	


    public static final String TABLE = "agent_user";

    /** */
	public static final String ALIAS_AGENT_UID = "agent_uid";
    /** */
	public static final String ALIAS_AGENT_ID = "agent_id";
    /** */
	public static final String ALIAS_USER_NAME = "user_name";
    /**用户类型: 1 企业默认管理员,2 普通用户 */
	public static final String ALIAS_USER_TYPE = "user_type";
    /**账号 */
	public static final String ALIAS_ACCOUNT = "account";
    /**密码 */
	public static final String ALIAS_PASSWORD = "password";
    /**手机 */
	public static final String ALIAS_TEL = "tel";
    /** */
	public static final String ALIAS_STATE = "state";
    /**创建时间 */
	public static final String ALIAS_CREATE_TIME = "create_time";
    /**修改时间 */
	public static final String ALIAS_UPDATE_TIME = "update_time";
    /**邮箱 */
	public static final String ALIAS_EMAIL = "email";
    /**性别 */
	public static final String ALIAS_SEX = "sex";
	
	

 	@Id
@   GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "agent_uid", unique = true, nullable = false)
    public java.lang.Long agentUid;
  
 	@Column(name = "agent_id")
    public java.lang.Long agentId;
  
 	@Column(name = "user_name")
    public java.lang.String userName;
  
 	@Column(name = "user_type")
    public java.lang.Long userType;
  
 	@Column(name = "account")
    public java.lang.String account;
  
 	@Column(name = "password")
    public java.lang.String password;
  
 	@Column(name = "tel")
    public java.lang.String tel;
  
 	@Column(name = "state")
    public java.lang.Long state = 1l;
  
 	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "create_time")
    public java.util.Date createTime;
  
 	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "update_time")
    public java.util.Date updateTime;
  
 	@Column(name = "email")
    public java.lang.String email;
  
 	@Column(name = "sex")
    public java.lang.String sex;
  





	public java.lang.Long getAgentUid() {
		return this.agentUid;
	}
	
	public void setAgentUid(java.lang.Long value) {
		this.agentUid = value;
	}

	public java.lang.Long getAgentId() {
		return this.agentId;
	}
	
	public void setAgentId(java.lang.Long value) {
		this.agentId = value;
	}

	public java.lang.String getUserName() {
		return this.userName;
	}
	
	public void setUserName(java.lang.String value) {
		this.userName = value;
	}

	public java.lang.Long getUserType() {
		return this.userType;
	}
	
	public void setUserType(java.lang.Long value) {
		this.userType = value;
	}

	public java.lang.String getAccount() {
		return this.account;
	}
	
	public void setAccount(java.lang.String value) {
		this.account = value;
	}

	public java.lang.String getPassword() {
		return this.password;
	}
	
	public void setPassword(java.lang.String value) {
		this.password = value;
	}

	public java.lang.String getTel() {
		return this.tel;
	}
	
	public void setTel(java.lang.String value) {
		this.tel = value;
	}

	public java.lang.Long getState() {
		return this.state;
	}
	
	public void setState(java.lang.Long value) {
		this.state = value;
	}

	public java.util.Date getCreateTime() {
		return this.createTime;
	}
	
	public void setCreateTime(java.util.Date value) {
		this.createTime = value;
	}

	public java.util.Date getUpdateTime() {
		return this.updateTime;
	}
	
	public void setUpdateTime(java.util.Date value) {
		this.updateTime = value;
	}

	public java.lang.String getEmail() {
		return this.email;
	}
	
	public void setEmail(java.lang.String value) {
		this.email = value;
	}

	public java.lang.String getSex() {
		return this.sex;
	}
	
	public void setSex(java.lang.String value) {
		this.sex = value;
	}


	
	public AgentUser() {
	}
	
	public AgentUser(boolean qryflag) {
	    if(qryflag){
	    		this.agentUid = null;
				this.agentId = null;
				this.userName = null;
				this.userType = null;
				this.account = null;
				this.password = null;
				this.tel = null;
				this.state = null;
				this.createTime = null;
				this.updateTime = null;
				this.email = null;
				this.sex = null;
			    }
	}


	public AgentUser(
	    java.lang.Long inAgentUid,
	    java.lang.Long inAgentId,
	    java.lang.String inUserName,
	    java.lang.Long inUserType,
	    java.lang.String inAccount,
	    java.lang.String inPassword,
	    java.lang.String inTel,
	    java.lang.Long inState,
	    java.util.Date inCreateTime,
	    java.util.Date inUpdateTime,
	    java.lang.String inEmail,
		java.lang.String inSex
	 ) {
		super();
				this.agentUid = inAgentUid;
				this.agentId = inAgentId;
				this.userName = inUserName;
				this.userType = inUserType;
				this.account = inAccount;
				this.password = inPassword;
				this.tel = inTel;
				this.state = inState;
				this.createTime = inCreateTime;
				this.updateTime = inUpdateTime;
				this.email = inEmail;
				this.sex = inSex;
			}


    @Transient
    private String ext1;

    public String getExt1() {
        return ext1;
    }

    public void setExt1(String ext1) {
        this.ext1 = ext1;
    }

    public static String checkAgentUser(AgentUser user) throws ViChatException {
        if (StringUtils.isNotBlank(user.getAccount())) {
            if (StringUtil.isSpecialChar(user.getAccount())) {
                return I18nConstant.error_accountSpecialChar;
            }
            if (user.getAccount().length() > 20) {
                return I18nConstant.error_accountTooLong;
            }
        }
        if (StringUtils.isNotBlank(user.getUserName())) {
//            if (StringUtil.isSpecialChar(user.getUserName())) {
//                return I18nConstant.error_userNameSpecialChar;
//            }
            if (user.getUserName().length() > 20) {
                return I18nConstant.error_userNameTooLong;
            }
        }
        return null;
    }


}

